package com.egg.common.spring.enums.sensitive;

import cn.hutool.core.util.DesensitizedUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.function.Function;

/**
 * 脱敏策略
 */
@Getter
@AllArgsConstructor
public enum SensitiveStrategyEnum {


    ID_CARD("身份证脱敏", s -> DesensitizedUtil.idCardNum(s, 3, 4)),

    PHONE("手机号脱敏", DesensitizedUtil::mobilePhone),

    ADDRESS("地址脱敏", s -> DesensitizedUtil.address(s, 8)),

    EMAIL("邮箱脱敏", DesensitizedUtil::email),

    BANK_CARD("银行卡脱敏", DesensitizedUtil::bankCard);

    //可自行添加其他脱敏策略
    private String message;
    private final Function<String, String> desensitizer;

    public Function<String, String> desensitizer() {
        return desensitizer;
    }
}
